<?php
namespace products;

use Exception;

abstract class BankProduct {
	
	protected $accountName;
	protected $interestPerYear;
	protected $timePeriod;
	protected $currentMoneyAmount;
	
	public function __construct($accountName, $interestPerYear, $timePeriod, $currentMoneyAmount ) {
		
		$this->setAccountName($accountName);
		$this->setInterestPerYear($interestPerYear);
		$this->setTimePeriod($timePeriod);
		$this->setCurrentMoneyAmount($currentMoneyAmount);
		
	}
	
	public function __destruct() {
	
	}
	
	public function setAccountName($accountName) {
		
		if($accountName == "" || $accountName == NULL) {
				
			throw new Exception("Account name parameter can't be null or empty string");
		}
		
		if(!is_string($accountName)) {
				
			throw new Exception("Account name parameter mus be a string value!");
		}
		
		$this->accountName = $accountName;
	}
	
	public function getAccountName() {
		
		return $this->accountName;
	}
	
	public function setInterestPerYear($interestPerYear) {
		
		if($interestPerYear == "" || $interestPerYear == NULL) {
		
			throw new Exception("Interest per year parameter can't be null or empty string");
		}
		
		if(!is_numeric($interestPerYear)) {
			
			throw new Exception("Interest per year parameter must be a numeric value!");
		}
		
		if($interestPerYear <= 0) {
			
			throw new Exception("Interest per year parameter must be positive value!");
		}
		
		$this->interestPerYear = $interestPerYear;
	}
	
	public function getInterestPerYear() {
		
		return $this->interestPerYear;
	}
	
	public function setTimePeriod($timePeriod) {
		
		if($timePeriod == "" || $timePeriod == NULL) {
		
			throw new Exception("Time period parameter can't be null or empty string");
		}
		
		if(!is_int($timePeriod)) {
				
			throw new Exception("Time period parameter must be an integer value!");
		}
		
		if($timePeriod <= 0 || $timePeriod > 60) {
				
			throw new Exception("Time period value must e between 1 and 60!");
		}
		
		$this->$timePeriod = $timePeriod;
	}
	
	public function getTimePeriod() {
		
		return $this->timePeriod;
		
	}
	
	public function setCurrentMoneyAmount($currentMoneyAmount) {
		
		if($currentMoneyAmount == "" || $currentMoneyAmount == NULL) {
		
			throw new Exception("Available money amount parameter can't be null or empty string");
		}
		
		if(!is_numeric($currentMoneyAmount)) {
		
			throw new Exception("Time period parameter must be an integer value!");
		}
		
		$this->currentMoneyAmount = $currentMoneyAmount;
		
	}
	
	public function getCurrentMoneyAmount() {
		
		return $this->currentMoneyAmount;
	}
}